home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / BIOSDISK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1.2 KB  |  46 lines

  1. /* biosdisk.c --- p560 */
  2. #include <stdio.h>
  3. #include <dos.h>
  4. #include <bios.h>
  5. #define DOS_DISPCHAR  2
  6. #define DISK_READ     2
  7. main()
  8. {
  9.     int i, j, retry, strt;
  10.     unsigned ch_out, status =0;
  11.     char buf[512];
  12.     int drive, head, track, sector, nsectors;
  13.                     /* Set up diskette information */
  14.     drive = 0; /* Drive A, use 1 for drive B */
  15.     head =0;
  16.     track =0;
  17.     sector =6; /* Location of first directory entry for DSDD diskettes*/
  18.     nsectors = 1;
  19.         /* Read sector making up to 3 retries. Retries are
  20.          * necessary to make sure that any error is not due to
  21.          * motor start-up delay. See explanation for error code
  22.          * 80h above. */
  23.     for(retry =0; retry<=3; retry++)
  24.     {
  25.         if((status = biosdisk(DISK_READ, drive, head,
  26.             track, sector, nsectors, buf)) ==0)
  27.         {
  28.             printf("Read OK .\n");
  29.             printf("First 10 directory entries are:\n");
  30.             for(i=0; i<10;i++)
  31.             {
  32.                 strt = 32*i; /* Each entry is 32 bytes */
  33.                         /* Each name is 11 bytes */
  34.                 for(j=0; j<11; j++)
  35.                 {
  36.                     ch_out = buf[strt+j];
  37.                     bdos(DOS_DISPCHAR, ch_out, 0);
  38.                 }
  39.                 printf("\n");
  40.             }
  41.             exit(0);
  42.         }
  43.     }
  44.             /* Read failed despite 3 retries. Report error */
  45.     printf("Error reading from diskette! status=%x\n", status);
  46. }